import 'package:flutter/material.dart';
import '../tbicons.dart';
import '../utils/tools.dart';
import '../models/article_comment_model.dart';

class CommentWidget extends StatelessWidget {
  final ArticleCommentModel model;

  const CommentWidget({Key? key, required this.model}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final textStyle = Theme.of(context).textTheme.caption;
    final iconColor = textStyle?.color;
    double iconSize = 18;
    return Card(
      elevation: 0,
      margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
      child: Padding(
        padding: const EdgeInsets.all(5),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                CircleAvatar(
                  child: Tools.avatar(model.avatar),
                  backgroundColor: Colors.transparent,
                ),
                const SizedBox(width: 10),
                Text(model.nickName),
                Expanded(child: Container()),
                IconButton(
                  onPressed: () {},
                  iconSize: iconSize,
                  icon: const Icon(Tbicons.more),
                ),
              ],
            ),
            Padding(
              padding: const EdgeInsets.all(15),
              child: Text(model.content),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                Icon(
                  Tbicons.time,
                  color: iconColor,
                  size: textStyle?.fontSize,
                ),
                Text(
                  Tools.formatDateFromTimestamp(model.createTime),
                  style: Theme.of(context).textTheme.caption,
                ),
                Expanded(child: Container()),
                IconButton(
                  iconSize: iconSize,
                  onPressed: () {},
                  icon: Icon(Tbicons.appreciate_light, color: iconColor),
                ),
                IconButton(
                  iconSize: iconSize,
                  onPressed: () {},
                  icon: Icon(Tbicons.oppose_light, color: iconColor),
                ),
                IconButton(
                  iconSize: iconSize,
                  onPressed: () {},
                  icon: Icon(Tbicons.comment_light, color: iconColor),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
